package com.grep.extra.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.grep.base.db.DBUtils;
import com.grep.extra.dao.BaseDao;

public class BaseDaoImpl implements BaseDao {
	
	

	private static Logger logger = LoggerFactory.getLogger(BaseDaoImpl.class);
	

	public boolean insert(String insertSQL) {
		Connection conn = null;
		PreparedStatement pstmt = null; 
		
		try {
			conn = DBUtils.getConnection();
			pstmt = conn.prepareStatement(insertSQL);
			int result = pstmt.executeUpdate();
			if(result != 1){
				return false;
			}
		} catch (SQLException e) {
 			e.printStackTrace();
			logger.error("there have a exception when insert data to web_site");
			return false;
		}finally{
			 
			DBUtils.close(pstmt);
			DBUtils.close(conn);
			
		}
		
		return true;
	}
	
//	public ResultSet select(String selectSql) {
//		
//		Connection conn = null;
//		Statement stat = null;
//		ResultSet result =null;
//				
//		try {
//			conn = DBUtils.getConnection();
//			stat = conn.createStatement();
//			result = stat.executeQuery(selectSql);
//		} catch (SQLException e) {
//			e.printStackTrace();
//			logger.error("there have a exception when select data to database");
//		} finally{ 
//		//	DBUtils.close(stat);
//			//DBUtils.close(conn);
//			
//		}
//		return result;
//	}
	
}
	 

 
